package com.springcloudemo.ms.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("hello")
public class EurekaController {

    @Autowired
    private RestTemplate restTemplate;

    /**
     * 测试eureka
     * @param id
     * @return
     */
    @GetMapping("test/{id}")
    public String test(@PathVariable String id) {
        String forObject = restTemplate.getForObject("http://eureka-provider/hello/test/" + id, String.class);
//        String forObject = restTemplate.getForObject("http://localhost:9000/hello/test/" + id, String.class);

        return forObject;
    }
}
